package com.meritit.portal.login.bean;

import java.io.Serializable;

import org.apache.log4j.Logger;

import com.meritit.portal.util.PropertiesUtil;

/**
 * 配置信息实体类，用于加载和保存配置信息
 * 
 * @author com.meritit zhangxh
 * @since 2014-08-19
 */
public class PreferenceBean implements Serializable {
	private static final long serialVersionUID = 2862665945306820614L;
	private static Logger log = Logger.getLogger(PreferenceBean.class);
	public static int displayRows;
	public static String datasourceEnable;
	public static String jndiName;
	public static String jdbcDriver;
	public static String jdbcUrl;
	public static String jdbcUserName;
	public static String jdbcPassword;

	/**
	 * 获取加载配置信息，读取配置文件中的信息。
	 * 
	 * @return PreferenceBean
	 */
	public static void loadPreferences() throws Exception {
		try {
			PreferenceBean.displayRows = PropertiesUtil.getInt("ssosystem.itemsInPage", 10);
			PreferenceBean.datasourceEnable = PropertiesUtil.getText("datasource.enable");
			PreferenceBean.jndiName = PropertiesUtil.getText("jndi.name");
			PreferenceBean.jdbcDriver = PropertiesUtil.getText("jdbc.driver");
			PreferenceBean.jdbcUrl = PropertiesUtil.getText("jdbc.url");
			PreferenceBean.jdbcUserName = PropertiesUtil.getText("jdbc.username");
			PreferenceBean.jdbcPassword = PropertiesUtil.getText("jdbc.password");
		} catch (Exception e) {
			log.error("读取首选项信息错误：" + e.getMessage());
			throw e;
		}
	}
}
